
var sepStr =  ":::" ;

function QStrParser ( href )
{
	this.m_params = new Array();

	var qStr = "" ;
	if ( ! href ) 
	{
		qStr = window.document.location.search.slice( 1 );
	}
	else
	{
		var pos = href.indexOf( '?' );
		if ( pos != -1 )
		{
			qStr = href.slice( pos + 1 );
		}
	}
	if ( !qStr ) return ;	

	var param, paramName, paramValue ;
	var tmp = qStr.split( "&" );
	for ( var i = 0; i < tmp.length; i++ )
	{
		param = tmp[ i ].split( "=" );
		paramName = unescape( param[ 0 ] );
		paramValue = ( param[ 1 ] ? unescape( param[ 1 ] ) : "" );

		this.setParam( paramName, paramValue, 1 );
	}
}

QStrParser.prototype.toString = function ()
{
	var s = "" ;
	for ( var paramName in this.m_params )
	{
		aTemp = this.m_params[ paramName ].split( sepStr );
		for ( var i = 0; i < aTemp.length; i++ )
		{
			if ( s != "" )
			{
				s += "&" ;
			}

			s += escapePlus( paramName ) + "=" + escapePlus( aTemp[ i ] );
		}
	}

	return s ;

}	// QStrParser.prototype.toString

QStrParser.prototype.getParam = function ( paramName )
{
	if ( this.m_params[ paramName ] && 
		 ( -1 != this.m_params[ paramName ].indexOf( sepStr ) ) )
	{
		return this.m_params[ paramName ].split( sepStr );
	}

	return this.m_params[ paramName ];
}

QStrParser.prototype.setParam = function ( paramName, paramValue, fAppend )
{
	if ( paramValue == null ) 
		paramValue = "" ;

	if ( ! fAppend )
	{
		this.m_params[ paramName ] = paramValue ;
	}
	else
	{
		if ( this.m_params[ paramName ] == null )
		{
			this.m_params[ paramName ] = "" ;
		}
		else if ( this.m_params[ paramName ] != "" )
		{
			this.m_params[ paramName ] += sepStr ;
		}

		this.m_params[ paramName ] += paramValue ;
	}

	return this.m_params[ paramName ];
}

QStrParser.prototype.delParam = function ( paramName )
{
	delete this.m_params[ paramName ];
	return null ;
}

QStrParser.prototype.fillForm = function ( form )
{
	if ( ! form ) return  ;

	for ( var paramName in this.m_params )
	{
		if ( typeof( form[ paramName ] ) == "object" )
		{
			aTemp = this.m_params[ paramName ].split( sepStr );
			for ( var i = 0; i < aTemp.length; i++ )
			{
				setCtrlValue( form[ paramName ],  aTemp[ i ] );
			}
		}
	}

}	// QStrParser.prototype.fillForm


